package vip.zhenzicheng.design_patterns.iterator;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zhenzicheng
 * @date 2022-05-27 13:37
 */
public class StudentAggregateImpl implements StudentAggregate {

    private final List<Student> list = new ArrayList<>();

    @Override
    public void addStudent(Student stu) {
        list.add(stu);
    }

    @Override
    public void removeStudent(Student stu) {
        list.remove(stu);
    }

    @Override
    //获取迭代器对象
    public StudentIterator getStudentIterator() {
        return new StudentIteratorImpl(list);
    }
}
